<?php
session_start();
include "Includes/solotrn_sesion.php";
include "Includes/soloFun_Generales.php";
require_once "config.php";
require_once "Includes/conexion.class.php";

$CboNodo = $_REQUEST["CboNodo"];
//'TopNodo = ObtenerPrimerNodosql
//'if CboNodo = "" then CboNodo = TopNodo	'si es blanco le asigno el primer valor
//'StrCboNodo = Cargar_nodo_usuariosql(CboNodo, "CboNodo", "style='width:202' onChange='ConsultaPerfil();'")
$TopNodo = 1;
if (empty($CboNodo)) $CboNodo = $TopNodo;	//'si es blanco le asigno el primer valor
SoloFun_ExecSql ("select * from solotb_nodos", $SoloArrNodos);
$StrCboNodo = SoloFun_CargaCombo($SoloArrNodos,"CboNodo","$CboDisabled",$itemselec," class='SoloStyle_Texto' style='width:200'","");

$pageaction = "solotrn_ConsultarPerfil.php";

$strSql = "select * from solotb_perfil where nodo = $CboNodo order by ds_perf";
//' response.write strsql
$oConexion = new Conexion($WORKFLOW["motor_base"], $WORKFLOW["db_usuario"], $WORKFLOW["db_password"],
        $WORKFLOW["basedatos"], $WORKFLOW["servidor"], $WORKFLOW["flags"], $WORKFLOW["encoding"]);
///'ObjPerfil.Open strSql,Session("SoloConn")
$bandPerfil = false;
if(!$oConexion->EjecutarQuery($strSql)) {
    $strERROR = 1;
    $err = 0;
}else {
    $bandPerfil = true;
    $arrPerfil = $oConexion->getData("NUM");
    $oConexion->liberarResultado();
//'	  response.write Ubound(arrPerfil,2)
}
$oConexion->Cerrar();
//'response.write "<br>valcboperfil="&valcboperfil
//'response.write "<br>CmbPerfil="&$_REQUEST["CmbPerfil")
$strSql = "select distinct a.co_modu, b.ds_modu  from solotb_perfil_modulo a, solotb_modulo b, solotb_nodos c where a.co_modu=b.co_modu";

if (!empty($_REQUEST["CmbPerfil"]) && empty($_REQUEST["hidperfil"])) {
//'   if $_REQUEST["CmbPerfil")<>"" then
    $strSql .= " and a.co_perf=" . $_REQUEST["CmbPerfil"];
    $iPerfil = $_REQUEST["CmbPerfil"];
}else {
    $strSql .= " and a.co_perf=" . $arrPerfil[0][0];
    $iPerfil = $arrPerfil[0][0];
}
//'   $strSql .= " and b.nodo="&CboNodo
$strSql .= " and c.id = a.nodo and c.id=b.nodo and c.id=".$CboNodo;
$strSql .= " order by a.co_modu";
//'   response.write "<br> consul strSql = " & strSql

$oConexion = new Conexion($WORKFLOW["motor_base"], $WORKFLOW["db_usuario"], $WORKFLOW["db_password"],
        $WORKFLOW["basedatos"], $WORKFLOW["servidor"], $WORKFLOW["flags"], $WORKFLOW["encoding"]);
//'Obj.Open strSql,Session("SoloConn")
//Obj.Open strSql,Session("SoloConn")
$bandMod = false;
if(!$oConexion->EjecutarQuery($strSql)) {
    $strERROR = 1;
    $err = 0;
}else {
    $bandMod = true;
    $arrModulos = $oConexion->getData("NUM");
    $oConexion->liberarResultado();
}
$oConexion->Cerrar();
?>
<html>
    <head>
        <title>SoloPortal - Consulta de Perfil</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <link rel="stylesheet" href="SoloStyles/Solostyles.css" type="text/css">
        <SCRIPT type="text/JavaScript" src="Includes/Solofun_generales.js"></SCRIPT>
    </head>
    <body topmargin=0 leftmargin=0 onkeydown="checkKey();">
        <img src="templates/SoloTemplate_LogoCabecera.png" style="height: 50px"/>
        <!-- Include File="Includes/solotrn_header.asp" -->
        <p align="center" class="SoloStyle_TituloPaginas">Consultar Perfiles</p>
        <form name="frm" action="<?php echo $pageaction;?>" method="POST">
            <table border="0" width="60%" align="center" cellpadding="2" cellspacing="1" bordercolor="#CCCCCC">
                <tr>
                    <td>
                        <img src="iconos/soloico_salir.gif" border="1" alt="Salir" style="cursor:hand" onClick="window.opener.location.reload();window.close();" >
                    </td>
            </table>
            <table width="50%" border="0" align="center" cellpadding="2" cellspacing="1">
                <tr>
                    <td class="SoloStyle_Etiqueta">Empresa</td>
                    <td class="SoloStyle_EtiquetaCajas"><?php echo $StrCboNodo; ?></td>
                </tr>
                <tr>
                    <td class="SoloStyle_Etiqueta"><b>M&oacute;dulo</b></td>
                    <td class="SoloStyle_EtiquetaCajas">
                        <select name="CmbPerfil" class="SoloStyle_Texto" style="width:202" Onchange="javascript:document.frm.submit();" disabled="disabled">
                            <?php for ($i = 0; $i < count($arrPerfil); $i++) {
                                $ind = $arrPerfil[$i][0];
                                $jnd = $_REQUEST["CmbPerfil"];
                                if ($jnd == $ind) {
                                    echo "<option value='$ind' SELECTED >". $arrPerfil[$i][1] . "</option>";
                                    $valcboperfil = $arrPerfil[$i][0];
                                }else
                                    echo "<option value='$ind'>" . $arrPerfil[$i][1] . "</option>";

                            }
                            if (empty($valcboperfil)) $valcboperfil = $arrPerfil[0][0];
                            ?>
                        </select>
                        <input type="hidden" maxlenght="50" size="50" name="HidId" class="texto" value="<?php echo $MaxId;?>">
                        <input type="hidden" name="valcboperfil" value="<?php echo $valcboperfil;?>">
                        <input type="hidden" name="hidperfil">
                    </td>
                </tr>
            </table>
            <br>
            <?php $looper = 0;?>

            <table width="90%" border="1" cellpadding="0" cellspacing="1" align="center" bordercolor="#CCCCCC">
                <?php if ($bandMod) {
                    for ($i = 0; $i < count($arrModulos); $i++) {
                        if ($looper == 0) {?>
                <!-- crea una nueva fila para 2 modulos-->
                <tr><td width="50%" valign="top" class="SoloStyle_grid">
                                    <?php }else { ?>
                        <!-- crea la segunda columna de la fila-->
                    <td width="50%" valign="top" class="SoloStyle_grid">
                                    <?php } ?>

                        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="SoloStyle_grid">
                            <tr>

                                <td colspan="2" class="SoloStyle_Etiqueta" height="20"> &nbsp;<?php echo $arrModulos[$i][1]; ?></td>
                            </tr>
                                    <?php
                                    $oConexion = new Conexion($WORKFLOW["motor_base"], $WORKFLOW["db_usuario"], $WORKFLOW["db_password"],
                                            $WORKFLOW["basedatos"], $WORKFLOW["servidor"], $WORKFLOW["flags"], $WORKFLOW["encoding"]);
//'strSql="select * from solotb_modulo_transaccion where co_modu=" & arrmodulos(0,i)
                                    $strSql = "select distinct a.co_tran,a.co_modu, b.ds_tran ";
                                    $strSql .= "from solotb_perfil_modulo a, solotb_modulo_transaccion b, solotb_nodos c ";
                                    $strSql .= "where a.co_tran = b.co_tran and a.co_modu=b.co_modu ";
                                    $strSql .=" and c.id = a.nodo and c.id = b.nodo  and a.nodo=" . $CboNodo;
                                    $strSql .= " and a.co_perf=" . $valcboperfil . " and a.co_modu=" . $arrModulos[$i][0];

//'response.write "<br>strSql = " & strSql
//'ObjTran.Open strSql,Session("SoloConn")
//ObjTran.Open strSql,Session("SoloConn")
                                    $bandTran = false;
                                    if (!$oConexion->EjecutarQuery($strSql)) {
                                        $strERROR = 1;
                                        $err = 0;
                                    }else {
                                        $bandTran = true;
                                        $arrTransacciones = $oConexion->getData("NUM");
                                        $oConexion->liberarResultado();
                                    }
                                    $oConexion->Cerrar();
                                    ?>
                            <tr>
                                <td>
                                            <?php if ($bandTran) {
                                                for ($j = 0; $j < count($arrTransacciones); $j++) { ?>
                                    &nbsp;&nbsp;
                                                    <?php echo $arrTransacciones[$j][2]; ?><br>
                                                    <?php }
                                            } ?>
                                </td>
                            </tr>
                        </table>

                                <?php if ($looper == 1) {?>
                        <!-- cierra columna 2 de la fila y cierra la fila-->
                    </td></tr>
                            <?php $looper = 0;
                        }else {?>
                <!-- cierra columna 1 de la fila-->
                </td>
                            <?php $looper = 1;?>
                            <?php } ?>
                        <?php }
                }
                if ($looper == 1) {?>
                &nbsp;</tr>
                    <?php } ?>
            </table>
        </form>
        <br>
    </body>
</html>
<script type="text/JavaScript">
    function ConsultaPerfil(){
        frm.hidperfil.value='C';
        frm.submit();
    }
</script>

<?php
include "Includes/soloFun_ShowMessages.php";
?>

